package com.yuxin.spirngboot.entity;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

//如果想要使用全局配置文件中的属性，必须将此声明为一个组件
@Component

// 从全局配置文件中映射属性
@ConfigurationProperties(prefix = "person")

// 从属性配置文件中映射属性，需要使用@Value("${lastName}")，如果同时有@ConfigurationProperties和@PropertySource，优先选择@ConfigurationProperties
@PropertySource(value = { "classpath:person.properties" })
public class Person {

	@Value("${lastName}")
	private String lastName;
	private Integer age;
	private Boolean boss;
	private Date birth;
	private Map<String, Object> maps;
	private List<Object> lists;
	private Dog dog;

	public Person() {
		super();
	}

	public Integer getAge() {
		return age;
	}

	public Date getBirth() {
		return birth;
	}

	public Boolean getBoss() {
		return boss;
	}

	public Dog getDog() {
		return dog;
	}

	public String getLastName() {
		return lastName;
	}

	public List<Object> getLists() {
		return lists;
	}

	public Map<String, Object> getMaps() {
		return maps;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public void setBirth(Date birth) {
		this.birth = birth;
	}

	public void setBoss(Boolean boss) {
		this.boss = boss;
	}

	public void setDog(Dog dog) {
		this.dog = dog;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public void setLists(List<Object> lists) {
		this.lists = lists;
	}

	public void setMaps(Map<String, Object> maps) {
		this.maps = maps;
	}

	@Override
	public String toString() {
		return "Person [lastName=" + lastName + ", age=" + age + ", boss=" + boss + ", birth=" + birth + ", maps="
				+ maps + ", lists=" + lists + ", dog=" + dog + "]";
	}
}
